package leetcode;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class LeetCode119 {

    public List<Integer> getRow(int rowIndex) {
        List<Integer> list = new ArrayList<>();
        Integer[] result = new Integer[rowIndex + 1];
        result[0] = 1;

        for (int i = 1; i < rowIndex + 1; i++) {
            result[i] = 1;
            for (int j = i; j > 1; j--)//每一行的更新过程
            {
                result[j - 1] = result[j - 2] + result[j - 1];
            }
        }
        Collections.addAll(list, result);
        return list;
    }

}
